<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java" import="java.util.*,java.lang.*" %>
<%@ page import="sg.edu.nus.iss.phoenix.radioprogram.entity.RadioProgram"%>
<html>
<head>
<link href="<c:url value='/css/main.css'/>" rel="stylesheet"
	type="text/css" />
<fmt:setBundle basename="ApplicationResources" />
<c:set var="t" value="true" />
<title>Program Page<fmt:message key="title.listprograms" /> </title>
<script	type="text/javascript">
	function selectProgram(name, duration) {

		var programs = document.getElementsByName("program");
		window.opener.document.getElementById('programName').value = name;
		window.opener.document.getElementById('duration').value = duration;
		self.close();
	}
</script>

</head>
<body>
  <div class="applicationTitle" align="center" width="100%"><fmt:message key="title.application"/></div>
	<br/>
	<div style="font-size:20px;" > <fmt:message key="label.program" /></div>
	<br/>
	<table>
		<%
			ArrayList programList = null;
			programList = (ArrayList) session.getAttribute("programList");
			for (int i = 0; i < programList.size(); i++) {
				RadioProgram radioProgram = (RadioProgram) programList.get(i);
		%>
		<tr>
			<td><input type="radio" id='<%=radioProgram.getName()%>'
				name="program" value='<%=radioProgram.getName()%>' onclick="selectProgram('<%=radioProgram.getName()%>', 
				'<%=radioProgram.getTypicalDuration().toString()%>');"/>
			</td>
			<td><%=radioProgram.getName()%></td>
		<tr>
			<%
				}
			%>
		
	</table>
</body>